package com.sirdc.modules.sys.web.index;

import com.sirdc.modules.core.web.JsonBaseController;
import com.sirdc.modules.core.web.model.Message;
import com.sirdc.modules.utils.ObjectUtils;
import com.sirdc.modules.utils.StringUtils;
import net.huashitong.Indicators.databean.CompletionClassificationDatabean;
import net.huashitong.Indicators.databean.IndicatorBreakdownDatabean;
import net.huashitong.Indicators.entity.CompletionClassification;
import net.huashitong.Indicators.entity.IndicatorBreakdown;
import net.huashitong.Indicators.entity.TertiaryIndustry;
import net.huashitong.Indicators.filter.CompletionClassificationFilter;
import net.huashitong.Indicators.filter.IndicatorBreakdownFilter;
import net.huashitong.Indicators.service.CompletionClassificationService;
import net.huashitong.Indicators.service.IndicatorBreakdownService;
import net.huashitong.Indicators.service.TertiaryIndustryService;
import net.huashitong.Indicators.utils.*;
import net.huashitong.scheduling.entity.CorporateTaxation;
import net.huashitong.scheduling.entity.FinanceRevenue;
import net.huashitong.scheduling.entity.IndustryRevenue;
import net.huashitong.scheduling.filter.ResourcesFilter;
import net.huashitong.scheduling.service.FinanceRevenueService;
import net.huashitong.scheduling.service.IndustryRevenueService;
import net.huashitong.scheduling.utils.IsUserUtils;
import net.huashitong.scheduling.web.RevenueController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.text.DecimalFormat;
import java.text.ParseException;
import java.util.*;

/**
 * 首页中间模块接口
 */
@Controller
@RequestMapping("/index/indicators/")
public class IndexIndicatorsController extends JsonBaseController {
    @Autowired
    private IndicatorBreakdownService breakdownService;
    @Autowired
    private TertiaryIndustryService industryService;
    @Autowired
    private CompletionClassificationService classificationService;
    @Autowired
    private FinanceRevenueService financeRevenueService;
    @Autowired
    private IndustryRevenueService industryRevenueService;
    public static final String[] months = {"12", "11", "10", "09", "08", "07", "06", "05", "04", "03", "02", "01"};
    public static final String[] years = {"2022", "2021", "2020", "2019", "2018", "2017"};

    @Override
    protected String getView(String arg0) {
        return null;
    }

    /**
     * 各个指标各个县区排名
     *
     * @param filter
     * @return
     */
    @ResponseBody
    @RequestMapping("/queryRanking")
    public Message queryRanking(@RequestBody IndicatorBreakdownFilter filter) {
        Map<String, Object> map = new HashMap<String, Object>();
        String judge = DataUtils.getValue(filter);
        String date = DataUtils.getValueMonth(judge, filter);
        filter.setCurrentMonth(date);
        List<IndicatorBreakdown> lists = breakdownService.queryByCuMonthAndAreaOR(filter);
        //县区列表
        List<String> areaList = new ArrayList<String>();
        //累计值列表
        List<String> cumulativeList = new ArrayList<String>();
        //增长率列表
        List<String> ratioList = new ArrayList<String>();
        DecimalFormat df = new DecimalFormat("#.##");
        for (IndicatorBreakdown in : lists) {
            areaList.add(in.getArea());
            if (StringUtils.isBlank(in.getCumulative()) || "0".equals(in.getCumulative())) {
                cumulativeList.add("-");
            } else {
                String val = in.getCumulative();
                Double strDouble = Double.parseDouble(Double.parseDouble(val) / 10000 + "");
                cumulativeList.add(df.format(strDouble));
            }
            ratioList.add(in.getRatio());
        }
        map.put("areaList", areaList);
        map.put("cumulativeList", cumulativeList);
        map.put("ratioList", ratioList);
        return coverMessage("200", "数据获取成功", map);
    }

    /**
     * 该指标发展情况
     *
     * @param filter
     * @return
     */
    @ResponseBody
    @RequestMapping("/queryInstrumentPanel")
    public Message queryInstrumentPanel(@RequestBody IndicatorBreakdownFilter filter) {
        Map<String, Object> map = new HashMap<String, Object>();
        String judge = DataUtils.getValue(filter);
        String date = DataUtils.getValueMonth(judge, filter);
        filter.setCurrentMonth(date);
        List<IndicatorBreakdown> lists2 = breakdownService.queryMonthDevelopmentSituation(filter);
        for (IndicatorBreakdown indicatorBreakdown : lists2) {

            if(StringUtils.isBlank(indicatorBreakdown.getRatio())){
                map.put("ratio", "0");   //增长率
            }else{
                map.put("ratio", indicatorBreakdown.getRatio());   //增长率
            }

        }
        TertiaryIndustry industries = industryService.queryByfilter(filter);
        map.put("cityIncrease", industries.getCityIncrease()); //市目标
        return coverMessage("200", "数据获取成功", map);
    }

    /**
     * 该指标累计同比增长情况
     *
     * @param filter
     * @return
     */
    @ResponseBody
    @RequestMapping("/queryCumulativeGrowth")
    public Message queryCumulativeGrowth(@RequestBody IndicatorBreakdownFilter filter) throws ParseException {
        Map<String, Object> map = new HashMap<String, Object>();
        String judge = DataUtils.getValue(filter);
        String date = DataUtils.getValueMonth(judge, filter);
        filter.setDate(DateForIndUtils.getMonth(date));
        //日期列表：1=季度/0=月份
        List<String> dateList = new ArrayList<String>();
        //标题列表
        List<String> titleList = new ArrayList<String>();
        //去年增长率列表
        List<String> currentYearRatioList = new ArrayList<String>();
        //本年增长率列表
        List<String> lastYearRatioList = new ArrayList<String>();
        //去年累计值列表
        List<String> currentYearCumulativeList = new ArrayList<String>();
        //本年累计值列表
        List<String> lastYearCumulativeList = new ArrayList<String>();
        //时间格式
        DecimalFormat df = new DecimalFormat("#.##");
        if ("0".contains(judge)) {
            dateList.add("02月");
            dateList.add("03月");
            dateList.add("04月");
            dateList.add("05月");
            dateList.add("06月");
            dateList.add("07月");
            dateList.add("08月");
            dateList.add("09月");
            dateList.add("10月");
            dateList.add("11月");
            dateList.add("12月");
            map.put("lastYearRatioTitle", DateForIndUtils.getNextYearDate(date.substring(0, 4), -1) + ThiTitleUtils.GYTBZZL);
            map.put("currentRatioTitle", date.substring(0, 4) + ThiTitleUtils.GYTBZZL);
            map.put("lastYearCumulativeTitle", DateForIndUtils.getNextYearDate(date.substring(0, 4), -1) + ThiTitleUtils.GYLJJDZ);
            map.put("currentYearCumulativeTitle", date.substring(0, 4) + ThiTitleUtils.GYLJJDZ);
            titleList.add(DateForIndUtils.getNextYearDate(date.substring(0, 4), -1) + ThiTitleUtils.GYTBZZL);
            titleList.add(date.substring(0, 4) + ThiTitleUtils.GYTBZZL);
            titleList.add(DateForIndUtils.getNextYearDate(date.substring(0, 4), -1) + ThiTitleUtils.GYLJJDZ);
            titleList.add(date.substring(0, 4) + ThiTitleUtils.GYLJJDZ);

            List<IndicatorBreakdownDatabean> breakdownDatabean3s = new ArrayList<IndicatorBreakdownDatabean>();
            filter.setDate(DateForIndUtils.getNextYearDate(filter.getDate().substring(0, 4), 0));
            List<IndicatorBreakdown> breakdown3s = breakdownService.queryMonthAbsolute(filter);
            breakdownDatabean3s = DataUtils.detailcumulativeData(breakdown3s, breakdownDatabean3s);
            filter.setDate(DateForIndUtils.getNextYearDate(filter.getDate(), -1));
            List<IndicatorBreakdown> breakdown3Ss = breakdownService.queryMonthAbsolute(filter);
            breakdownDatabean3s = DataUtils.detailcumulativeData(breakdown3Ss, breakdownDatabean3s);
            boolean flag = false;
            for (IndicatorBreakdownDatabean indicatorBreakdown : breakdownDatabean3s) {
                indicatorBreakdown.setCumulative(df.format(Double.parseDouble(indicatorBreakdown.getCumulative()) / 10000));
                if (indicatorBreakdown.getCurrentMonth().contains(filter.getDate().substring(0, 4))) {
                    lastYearRatioList.add(indicatorBreakdown.getRatio());
                    lastYearCumulativeList.add("0".equals(indicatorBreakdown.getCumulative())?"":indicatorBreakdown.getCumulative());

                    if(!flag){
                        Collections.reverse(currentYearRatioList);
                        Collections.reverse(currentYearCumulativeList);
                        flag = true;
                        continue;
                    }

                    currentYearRatioList.add("");
                    currentYearCumulativeList.add("");
                } else {
//                    currentYearCumulativeList.add("");
//                    currentYearRatioList.add("");
                    currentYearRatioList.add(indicatorBreakdown.getRatio());
                    currentYearCumulativeList.add(indicatorBreakdown.getCumulative());
                }
            }
        } else if ("1".contains(judge)) {
            dateList.add("第一季度");
            dateList.add("第二季度");
            dateList.add("第三季度");
            dateList.add("第四季度");
            map.put("lastYearRatioTitle", DateForIndUtils.getNextYearDate(date.substring(0, 4), -1) + ThiTitleUtils.GJTBZZL);
            map.put("currentRatioTitle", date.substring(0, 4) + ThiTitleUtils.GJTBZZL);
            map.put("lastYearCumulativeTitle", DateForIndUtils.getNextYearDate(date.substring(0, 4), -1) + ThiTitleUtils.GJLJJDZ);
            map.put("currentYearCumulativeTitle", date.substring(0, 4) + ThiTitleUtils.GJLJJDZ);
            titleList.add(DateForIndUtils.getNextYearDate(date.substring(0, 4), -1) + ThiTitleUtils.GJTBZZL);
            titleList.add(date.substring(0, 4) + ThiTitleUtils.GJTBZZL);
            titleList.add(DateForIndUtils.getNextYearDate(date.substring(0, 4), -1) + ThiTitleUtils.GJLJJDZ);
            titleList.add(date.substring(0, 4) + ThiTitleUtils.GJLJJDZ);

            filter.setDate(DateForIndUtils.getNextYearDate(filter.getDate().substring(0, 4), 0));
            List<IndicatorBreakdown> breakdowns = breakdownService.queryAbsoluteValue(filter);
            List<IndicatorBreakdownDatabean> breakdownDatabeans = new ArrayList<IndicatorBreakdownDatabean>();
            breakdownDatabeans = DataUtils.detailcumulativeData(breakdowns, breakdownDatabeans);
            filter.setDate(DateForIndUtils.getNextYearDate(filter.getDate(), -1));
            List<IndicatorBreakdown> breakdownSs = breakdownService.queryAbsoluteValue(filter);
            breakdownDatabeans = DataUtils.detailcumulativeData(breakdownSs, breakdownDatabeans);
            for (IndicatorBreakdownDatabean indicatorBreakdown : breakdownDatabeans) {
                indicatorBreakdown.setCumulative(df.format(Double.parseDouble(indicatorBreakdown.getCumulative()) / 10000));
                if (indicatorBreakdown.getCurrentMonth().contains(filter.getDate().substring(0, 4))) {
                    lastYearRatioList.add(indicatorBreakdown.getRatio());
                    lastYearCumulativeList.add("0".equals(indicatorBreakdown.getCumulative())?"":indicatorBreakdown.getCumulative());
                    currentYearRatioList.add("");
                    currentYearCumulativeList.add("");
                } else {
                    currentYearRatioList.add(indicatorBreakdown.getRatio());
                    currentYearCumulativeList.add(indicatorBreakdown.getCumulative());

                }
            }
        }
        Collections.reverse(lastYearRatioList);
        Collections.reverse(lastYearCumulativeList);
        map.put("dateList", dateList);
        map.put("titleList", titleList);
        map.put("currentYearRatioList", currentYearRatioList);
        map.put("lastYearRatioList", lastYearRatioList);
        map.put("currentYearCumulativeList", currentYearCumulativeList);
        map.put("lastYearCumulativeList", lastYearCumulativeList);
        return coverMessage("200", "数据获取成功", map);
    }

    /**
     * 第一产业 农林牧渔业该指标各行业分类占比情况
     */
    @ResponseBody
    @RequestMapping("/queryAgricultureForestry")
    public Message queryAgricultureForestry(@RequestBody IndicatorBreakdownFilter filter) {
        Map<String, Object> map = new HashMap<String, Object>();
        filter.setArea("永泰县");
        filter.setHy("行业");
        filter.setDate("201601-12");
        filter.setIndustryName("农林牧渔业总产值");
        //行业名称
        List<String> nameList = new ArrayList<String>();
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
        List<CompletionClassification> classifications = classificationService.queryByHYValueSec(filter);
        for (CompletionClassification completionClassification : classifications) {
            nameList.add(completionClassification.getCategoryDetails());
            Map<String, Object> maps = new HashMap<String, Object>();
            maps.put("name", completionClassification.getCategoryDetails());
            if (StringUtils.isBlank(completionClassification.getCompleteAnnual())) {
                maps.put("value", "0");
            } else {
                maps.put("value", completionClassification.getCompleteAnnual());
            }
            maps.put("actualCompletionValue", completionClassification.getActualCompletionValue());
            list.add(maps);
        }
        map.put("title", "各行业分类占比情况");
        map.put("nameList", nameList);
        map.put("list", list);
        return coverMessage("200", "数据获取成功", map);
    }

    /**
     * //税收分产完成统计
     *
     * @param filter
     * @return
     */
    @ResponseBody
    @RequestMapping("/taxComplete")
    public Message queryTertiaryIndustrytotal(@RequestBody IndicatorBreakdownFilter filter) {
        Map<String, Object> map = new HashMap<String, Object>();
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
        IndustryRevenue ir = new IndustryRevenue();
        String time = "";
        int ss = 0;
        if (ObjectUtils.isBlank(filter.getDate())) {
            for (int j = 0; j < RevenueController.years.length; j++) {
                if (ss == 1) {
                    break;
                }
                for (int i = 0; i < RevenueController.months.length; i++) {
                    ir = industryRevenueService.queryByName("合计", months[i], years[j]);
                    if (ObjectUtils.isNotBlank(ir)) {
                        time = years[j] + "年" + months[i] + "月";
                        ss = 1;
                        break;
                    }

                }
            }
        } else {
            String month = filter.getDate().substring(4, 6);
            String year = filter.getDate().substring(0, 4);
            ir = industryRevenueService.queryByName("合计", month, year);
        }
        if (ObjectUtils.isNotBlank(ir)) {
            List<IndustryRevenue> irlist = industryRevenueService.queryBySysId(ir.getSysId());
            map.put("units", ir.getUnits());
            map.put("yearIncome", ir.getYearIncome());
            map.put("lastyearIncome", ir.getLastyearIncome());
            map.put("increDecre", ir.getIncreDecre());
            for (IndustryRevenue irss : irlist) {
                Map<String, Object> map1 = new HashMap<String, Object>();
                map1.put("name", irss.getName());
                map1.put("value", irss.getIncreDecre());
                list.add(map1);
            }
            map.put("list", list);
            map.put("lists", irlist);
        }
        return coverMessage("200", "数据获取成功", map);
    }

    /**
     * 全省市、县（区）财政收支考核情况
     *
     * @param filter
     * @return
     */
    @ResponseBody
    @RequestMapping("/viewData")
    public Message queryFinancial(@RequestBody IndicatorBreakdownFilter filter) {
        List<FinanceRevenue> fList = new ArrayList<FinanceRevenue>();
        String time = "";
        String times = "";
        int ss = 0;
        if (ObjectUtils.isBlank(filter.getDate())) {
            for (int j = 0; j < RevenueController.years.length; j++) {
                if (ss == 1) {
                    break;
                }
                for (int i = 0; i < RevenueController.months.length; i++) {
                    fList = financeRevenueService.queryByDate(years[j] + months[i]);
                    if (ObjectUtils.isNotBlank(fList)) {
                        time = years[j] + "年" + months[i] + "月";
                        times = years[j] + months[i];
                        ss = 1;
                        break;
                    }
                }
            }
        } else {
            String month = filter.getDate().substring(4, 6);
            String year = filter.getDate().substring(0, 4);
            fList = financeRevenueService.queryByDate(filter.getDate());
        }
        return coverMessage("200", "数据获取成功", fList);
    }


    /**
     * 分业税收完成情况详细
     *
     * @return
     */
    @ResponseBody
    @RequestMapping("/queryTertiaryIndustry")
    public Message queryTertiaryIndustry(@RequestBody ResourcesFilter filter) {
        Map<String, Object> map = new HashMap<String, Object>();
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
        List<Map<String, Object>> incomelists = new ArrayList<Map<String, Object>>();
        IndustryRevenue ir = industryRevenueService.getById(filter.getSysId());
        List<IndustryRevenue> irlist = industryRevenueService.queryBySysId(filter.getSysId());
        for (IndustryRevenue irss : irlist) {
            Map<String, Object> map2 = new HashMap<String, Object>();
            map2.put("name", irss.getName());
            map2.put("value", irss.getYearIncome());
            incomelists.add(map2);
            Map<String, Object> map3 = new HashMap<String, Object>();
            map3.put("name", irss.getName());
            map3.put("currentYear", irss.getYearIncome());
            map3.put("lastYear", irss.getLastyearIncome());
            map3.put("increDecre", irss.getIncreDecre());
            map3.put("totalRatio", irss.getTotalRatio());
            map3.put("units", irss.getUnits());
            list.add(map3);
        }
        map.put("title", ir.getName());
        map.put("currentYear", ir.getYearIncome());
        map.put("lastYear", ir.getLastyearIncome());
        map.put("increDecre", ir.getIncreDecre());
        map.put("totalRatio", ir.getTotalRatio());
        map.put("units", ir.getUnits());
        map.put("currentYearList", incomelists);
        map.put("data", list);
        return coverMessage("200", "数据获取成功", map);
    }

    /**
     * GDP产业类
     *
     * @return
     */
    @ResponseBody
    @RequestMapping("/queryGDPIndustry")
    public Message queryGDPIndustry(@RequestBody IndicatorBreakdownFilter filter) throws ParseException {
        Map<String, Object> map = new HashMap<String, Object>();
        String judge = DataUtils.getValue(filter);
        String date = DataUtils.getValueMonth(judge, filter);
        filter.setDate(DateForIndUtils.getMonth(date));
        String cuDate = DateForIndUtils.getCMonth(filter.getDate());
        filter.setCurrentMonth(cuDate);
        //日期列表：1=季度/0=月份
        List<String> dateList = new ArrayList<String>();
        //标题列表
        List<String> titleList = new ArrayList<String>();
        //去年增长率列表
        List<String> lastYearRatioList = new ArrayList<String>();
        //本年增长率列表
        List<String> currentYearRatioList = new ArrayList<String>();
        //去年累计值列表
        List<String> lastYearCumulativeList = new ArrayList<String>();
        //本年累计值列表
        List<String> currentYearCumulativeList = new ArrayList<String>();
        //去年未完成部分
        List<String> lastYearNoCompleteList = new ArrayList<String>();
        //本年未完成部分
        List<String> currentYearNoCompleteList = new ArrayList<String>();
        //时间格式
        DecimalFormat df = new DecimalFormat("#.##");
        dateList.add("第一季度");
        dateList.add("第二季度");
        dateList.add("第三季度");
        dateList.add("第四季度");
        map.put("lastYearRatioTitle", DateForIndUtils.getNextYearDate(date.substring(0, 4), -1) + ThiTitleUtils.ZZL);
        map.put("currentRatioTitle", date.substring(0, 4) + ThiTitleUtils.ZZL);
        map.put("lastYearCumulativeTitle", DateForIndUtils.getNextYearDate(date.substring(0, 4), -1) + ThiTitleUtils.LJZ);
        map.put("currentYearCumulativeTitle", date.substring(0, 4) + ThiTitleUtils.LJZ);
        map.put("lastYearNoCompleteTitle", DateForIndUtils.getNextYearDate(date.substring(0, 4), -1) + ThiTitleUtils.WWCBF);
        map.put("currentYearNoCompleteTitle", date.substring(0, 4) + ThiTitleUtils.WWCBF);
        titleList.add(DateForIndUtils.getNextYearDate(date.substring(0, 4), -1) + ThiTitleUtils.ZZL);
        titleList.add(date.substring(0, 4) + ThiTitleUtils.ZZL);
        titleList.add(DateForIndUtils.getNextYearDate(date.substring(0, 4), -1) + ThiTitleUtils.LJZ);
        titleList.add(date.substring(0, 4) + ThiTitleUtils.LJZ);
        titleList.add(DateForIndUtils.getNextYearDate(date.substring(0, 4), -1) + ThiTitleUtils.WWCBF);
        titleList.add(date.substring(0, 4) + ThiTitleUtils.WWCBF);
        CompletionClassificationFilter classificationFilter = new CompletionClassificationFilter();
        classificationFilter.setArea(filter.getArea());
        classificationFilter.setIndicatorName(filter.getIndustryName());
        classificationFilter.setIndustryId(filter.getIndustryId());
        classificationFilter.setCategory("行业");
        classificationFilter.setCategoryDetails(filter.getXz());
        classificationFilter.setCompletionPeriod(filter.getDate());
        classificationFilter.setYear(filter.getCurrentMonth().substring(0, 4));
        List<CompletionClassification> lists = classificationService.queryByfilter(classificationFilter);
        List<CompletionClassificationDatabean> databeans = new ArrayList<CompletionClassificationDatabean>();
        for (CompletionClassification completionClassification : lists) {
            CompletionClassificationDatabean databean = new CompletionClassificationDatabean();
            databean.setActualCompletionValue(Double.toString((Double.parseDouble(completionClassification.getActualCompletionValue()) / 10000)).substring(0, 4));
            Double double1 = Double.parseDouble(completionClassification.getPlanneValue());
            Double double2 = Double.parseDouble(completionClassification.getActualCompletionValue());
            databean.setNoComplete(Double.toString(((double1 - double2) / 10000)).substring(0, 4));
            databean.setSpecificIncrease(completionClassification.getSpecificIncrease());
            databean.setYear(completionClassification.getYear());
            databean.setCompleteAnnual(completionClassification.getCompleteAnnual());
            databean.setCompletionPeriod(completionClassification.getCompletionPeriod());
            databeans.add(databean);
        }
        Collections.reverse(databeans);
        for (CompletionClassificationDatabean completionClassificationDatabean : databeans) {
            if (completionClassificationDatabean.getYear().equals(classificationFilter.getYear())) {
                currentYearNoCompleteList.add(completionClassificationDatabean.getNoComplete());
                currentYearRatioList.add(completionClassificationDatabean.getSpecificIncrease());
                currentYearCumulativeList.add(completionClassificationDatabean.getActualCompletionValue());
            } else {
                lastYearNoCompleteList.add(completionClassificationDatabean.getNoComplete());
                lastYearRatioList.add(completionClassificationDatabean.getSpecificIncrease());
                lastYearCumulativeList.add(completionClassificationDatabean.getActualCompletionValue());
            }
        }

        map.put("dateList", dateList);
        map.put("titleList", titleList);
        map.put("lastYearRatioList", lastYearRatioList);
        map.put("currentYearRatioList", currentYearRatioList);
        map.put("lastYearCumulativeList", lastYearCumulativeList);
        map.put("currentYearCumulativeList", currentYearCumulativeList);
        map.put("currentYearNoCompleteList", currentYearNoCompleteList);
        map.put("lastYearNoCompleteList", lastYearNoCompleteList);
        if ("第一产业".equals(filter.getXz())) {
            map.put("title", "地区生产总值(GDP)第一产业完成情况");
        } else if ("第二产业".equals(filter.getXz())) {
            map.put("title", "地区生产总值(GDP)第二产业完成情况");
        } else if ("第三产业".equals(filter.getXz())) {
            map.put("title", "地区生产总值(GDP)第三产业完成情况");
        }
        return coverMessage("200", "数据获取成功", map);
    }

    /**
     * 指标详细
     *
     * @param filter
     * @return
     */
    @ResponseBody
    @RequestMapping("/queryCompletionClassification")
    public Message queryCompletionClassification(@RequestBody IndicatorBreakdownFilter filter) throws ParseException {
        Map<String, Object> map = new HashMap<String, Object>();
        String judge = DataUtils.getValue(filter);
        String date = DataUtils.getValueMonth(judge, filter);
        filter.setDate(DateForIndUtils.getMonth(date));
        String cuDate = DateForIndUtils.getCMonth(filter.getDate());
        filter.setCurrentMonth(cuDate);
        List<CompletionClassification> classifications = classificationService.queryByValue(filter);
        List<CompletionClassification> classificationDatabeans2 = new ArrayList<CompletionClassification>();
        if ("部门".equals(filter.getBm()) && "A07".equals(filter.getIndustryId())) {
            Collections.sort(classifications, new ComparatorssUtils());
            int k = 10;
            if (classifications.size() < 10) {
                k = classifications.size();
            }
            for (int i = 0; i < k; i++) {
                classificationDatabeans2.add(classifications.get(i));
            }
        }
        DecimalFormat df = new DecimalFormat("#.##");
        //类别详细
        List<String> categoryDetailsList = new ArrayList<String>();
        //实际完成值
        List<String> actualCompletionValueList = new ArrayList<String>();
        //计划值
        List<String> planneValueList = new ArrayList<String>();
        //完成年计划
        List<String> completeAnnualList = new ArrayList<String>();
        //是否预警列表
        List<String> yujzList = new ArrayList<String>();
        if ("部门".equals(filter.getBm()) && "A07".equals(filter.getIndustryId())) {
            for (CompletionClassification completionClassification : classificationDatabeans2) {
                Double doublebs1 = Double.parseDouble(completionClassification.getActualCompletionValue());
                Double doublebs2 = Double.parseDouble(completionClassification.getPlanneValue());
                Double doublebs3 = doublebs1 / doublebs2 * 100;
                if (doublebs3 < DataUtils.warning(filter)) {
                    yujzList.add("1");
                } else {
                    yujzList.add("0");
                }
                String st = df.format(doublebs3);
                categoryDetailsList.add(completionClassification.getCategoryDetails());
                actualCompletionValueList.add(completionClassification.getActualCompletionValue());
                planneValueList.add(completionClassification.getPlanneValue());
                completeAnnualList.add(st);
            }
        } else {
            for (CompletionClassification completionClassification : classifications) {
                Double doublebs1 = Double.parseDouble(completionClassification.getActualCompletionValue());
                Double doublebs2 = Double.parseDouble(completionClassification.getPlanneValue());
                Double doublebs3 = doublebs1 / doublebs2 * 100;
                if (doublebs3 < DataUtils.warning(filter)) {
                    yujzList.add("1");
                } else {
                    yujzList.add("0");
                }
                String st = df.format(doublebs3);
                categoryDetailsList.add(completionClassification.getCategoryDetails());
                actualCompletionValueList.add(completionClassification.getActualCompletionValue());
                planneValueList.add(completionClassification.getPlanneValue());
                completeAnnualList.add(st);
            }
        }

        map.put("categoryDetailsList", categoryDetailsList);
        map.put("actualCompletionValueList", actualCompletionValueList);
        map.put("planneValueList", planneValueList);
        map.put("completeAnnualList", completeAnnualList);
        map.put("yujzList", yujzList);
        map.put("unit", "万元");
        if ("乡镇".equals(filter.getBm()) && "A07".equals(filter.getIndustryId())) {
            map.put("title", "分乡镇50万元以上固定资产投资总额完成情况");
        } else if ("部门".equals(filter.getBm()) && "A07".equals(filter.getIndustryId())) {
            map.put("title", "固定资产投资总额前十大部门累计完成情况");
        } else if ("项目".equals(filter.getBm()) && "A07".equals(filter.getIndustryId())) {
            map.put("title", "固定资产投资总额各项目完成情况");
        } else if ("乡镇".equals(filter.getBm()) && "A05".equals(filter.getIndustryId())) {
            map.put("title", "规模以上工业总产值各乡镇完成情况");
        } else if ("行业".equals(filter.getBm()) && "A05".equals(filter.getIndustryId())) {
            map.put("title", "规模以上工业总产值各行业完成情况");
        }
        return coverMessage("200", "数据获取成功", map);
    }
}
